package com.jps;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * create by lenovo 2020/9/29
 *
 *
 * */


@EnableBinding(Source.class)
@RestController
public class StreamSender {
    @Autowired
    private Source source;

    @GetMapping("/send/{msg}")
    public String send(@PathVariable String msg){
        MessageBuilder<String> builder = MessageBuilder.withPayload(msg);
        Message<String> message = builder.build();
        source.output().send(message);

        return "Hello RocketMQ Binder,send "+msg;
    }
}
